{
 "cells": [
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "# 1. input函数使用"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 1,
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "大圣想要什么礼物？定海神针\n",
      "定海神针 <class 'str'>\n",
      "请输入一个加数：13\n",
      "请输入另一个加数：24\n",
      "<class 'str'> <class 'str'>\n",
      "1324\n",
      "37\n"
     ]
    }
   ],
   "source": [
    "# 输入函数input\n",
    "present = input('大圣想要什么礼物？')\n",
    "print(present, type(present))  # str类型\n",
    "\n",
    "# input的高级使用\n",
    "# 从键盘录入两个整数，计算两个整数的和\n",
    "a = input('请输入一个加数：')\n",
    "b = input('请输入另一个加数：')\n",
    "print(type(a), type(b))\n",
    "print(a+b)  # 简单拼接str\n",
    "print(int(a) + int(b))  # 默认为str，需要转类型，或者用a=int(a)，转后输出a+b即可，或者用a=int(input('请输入一个加数：'))，提前转换"
   ]
  }
 ],
 "metadata": {
  "kernelspec": {
   "display_name": "Python 3.6.3",
   "language": "python",
   "name": "python3.6.3"
  },
  "language_info": {
   "codemirror_mode": {
    "name": "ipython",
    "version": 3
   },
   "file_extension": ".py",
   "mimetype": "text/x-python",
   "name": "python",
   "nbconvert_exporter": "python",
   "pygments_lexer": "ipython3",
   "version": "3.6.3"
  },
  "toc": {
   "base_numbering": 1,
   "nav_menu": {},
   "number_sections": false,
   "sideBar": true,
   "skip_h1_title": false,
   "title_cell": "Table of Contents",
   "title_sidebar": "Contents",
   "toc_cell": false,
   "toc_position": {},
   "toc_section_display": true,
   "toc_window_display": true
  }
 },
 "nbformat": 4,
 "nbformat_minor": 4
}
